package com.cheng.xbsc.controller;

import com.cheng.xbsc.entity.vo.Result;
import com.cheng.xbsc.service.SysOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class SysOrderController {

    @Autowired
    private SysOrderService sysOrderService;

    /**
     * 查询待收货订单
     *
     * @return
     */
    @GetMapping("/findOrder")
    public Result findOrder() {
        return new Result(true, "查询成功", sysOrderService.findByStatus("0"));
    }

    /**
     * 确定收货
     */
    @PutMapping("/doReceipt/{orderId}")
    public Result doReceipt(@PathVariable Integer orderId) {
        sysOrderService.updateStatus(orderId, "1");
        return new Result(true, "收货成功");
    }

    /**
     * 查询带待评价订单
     *
     * @return
     */
    @GetMapping("/findComment")
    public Result findComment() {
        return new Result(true, "查询成功", sysOrderService.findByStatus("1"));
    }

    /**
     * 评价商品
     */
    @PutMapping("/doComment/{orderId}")
    public Result doComment(@PathVariable Integer orderId) {
        sysOrderService.updateStatus(orderId, "2");
        return new Result(true, "评价成功");
    }
}
